/* --------------------------------------------------------
 * Copyright (c) aeky , Inc.  All rights reserved.
 * --------------------------------------------------------
 */
package com.aeky.server.rpcservice;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.aeky.client.rpcservice.LoginRPCService;
import com.aeky.model.User;
import com.aeky.server.service.ITestService;
import com.aeky.server.service.IUserService;
import com.aeky.server.support.ServletUtils;

/**
 * @author aeky
 */
@Service("loginRpc")
public class LoginRPCServiceImpl implements LoginRPCService {

    @Autowired
    private IUserService userService;

    @Autowired
    private ITestService testService;

    /*
     * 
     * @see
     * com.aeky.client.rpcservice.LoginService#login(com.smartgwt.client.data
     * .Record)
     */
    public User login(User record) {
        // testService.getAllMenuTest();
        // testService.getAllDeptTest();
        User user = userService.findUserByLoginName(record.getLoginName(), record.getPassword());
        HttpServletRequest request = ServletUtils.getRequest();
        request.getSession().setAttribute("user", user);
        return user;
    }

}
